{% extends "projects/project_edit_base.html" %}

{% load i18n %}

{% block title %}{% trans "Edit Domains" %}{% endblock %}

{% block nav-dashboard %} class="active"{% endblock %}

{% block editing-option-edit-proj %}class="active"{% endblock %}

{% block project-domains-active %}active{% endblock %}
{% block project_edit_content_header %}{% trans "Domains" %}{% endblock %}

{% block project_edit_content %}
  {% if superproject %}
    {% url "projects_detail" superproject.slug as superproject_url %}
    <p>
      {% blocktrans trimmed with superproject=superproject.name superproject_url=superproject_url domain=project.subdomain %}
        This project is a subproject of <a href="{{ superproject_url }}">{{ superproject }}</a>,
        its documentation will always be served from the <code>{{ domain }}</code> domain.
        <a href="https://docs.readthedocs.io/page/subprojects.html#custom-domain-on-subprojects">Learn more</a>.
      {% endblocktrans %}
    </p>
  {% else %}
    <p class="help_text">
      {% blocktrans trimmed with docs_url='https://docs.readthedocs.io/page/custom_domains.html' %}
          Configuring a custom domain allows you to serve your documentation from a domain other than "{{ default_domain }}". <a href="{{ docs_url }}">Learn more</a>.
      {% endblocktrans %}
    </p>
  {% endif %}

  {% if object_list %}
  <h3> {% trans "Existing Domains" %} </h3>
  <p>
    <ul>
    {% for domain in object_list %}
        <li class="{% if domain.machine %}domain-machine{% endif %} {% if domain.canonical %}domain-canonical{% endif %}" >
        {{ domain.domain }}
        (<a href="{% url 'projects_domains_edit' project.slug domain.pk %}">{% trans "Details" %}</a>)
        (<a href="{% url 'projects_domains_delete' project.slug domain.pk %}">{% trans "Remove" %}</a>)
        </li>
    {% endfor %}
    </ul>
  </p>
  {% endif %}

  {% if not superproject %}
    <h3>{% trans "Add new domain" %}</h3>

    {% if not enabled %}
      {% include 'projects/includes/feature_disabled.html' with project=project %}
    {% else %}
      <form method="post" action="{% url 'projects_domains_create' project.slug %}">{% csrf_token %}
        {{ form.as_p }}
        <p>
          <input style="display: inline;" type="submit" value="{% trans "Add" %}">
        </p>
      </form>
    {% endif %}
  {% endif %}
{% endblock %}
